package com.otojob.controller;


import com.otojob.dto.PageDto;
import com.otojob.entity.Job;
import com.otojob.entity.JobList;
import com.otojob.mapper.JobListMapper;
import com.otojob.service.JobListService;
import com.otojob.utils.Results;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import javax.validation.Valid;
import javax.validation.constraints.NotNull;

/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author TingFeng
 * @since 2022-03-28
 */
@Slf4j
@Api(value = "JobListController", tags = "查询职位分离列表")
@RestController
@CrossOrigin
@RequestMapping("/jobList")
public class JobListController {

    @Autowired
    private JobListService jobListService;

    @Resource
    private JobListMapper jobListMapper;



    @ApiOperation("查询职位列表分类")
    @GetMapping("findAllJobList")
    public Results findAllJobList(@Valid  PageDto pageDto){
        log.info("num"+pageDto.getPageNum()+"size"+pageDto.getPageSize() );

        return jobListService.findAllJobList(pageDto);
//        return Results.ok().data("lis",jobListMapper.findAllJobList(1,10));
    }

    @ApiOperation("添加职位列表")
    @PostMapping("addJobList")
    public Results addJobList(JobList job){
        return jobListService.addJobList(job);
    }

    @ApiOperation("查询职位列表")
    @PostMapping("findJobList")
    public Results findJobList(@Valid  PageDto pageDto, @NotNull String condition){
        log.info("num"+pageDto.getPageNum()+"size"+pageDto.getPageSize()+condition);
        return jobListService.findJobList(pageDto,condition);

    }
}

